﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ShredTheLog.Api.DataContracts;
using System.ComponentModel.Composition;
using System.ComponentModel;
using ShredTheLog.Api.DataContracts.TextChat;
using System.Windows.Media;
using System.Diagnostics.Contracts;

namespace ShredTheLog.Api
{
    [ContractClass(typeof(CommandListItem_Contract))]
    public interface ICommandListItem
    {
        string Name { get; }
        ImageSource Image { get; }
    }

    [ContractClassFor(typeof(ICommandListItem))]
    internal abstract class CommandListItem_Contract : ICommandListItem
    {
        string ICommandListItem.Name
        {
            get 
            {
                Contract.Ensures(Contract.Result<string>() != null);
                throw new NotImplementedException(); 
            }
        }

        ImageSource ICommandListItem.Image
        {
            get { throw new NotImplementedException(); }
        }
    }

    [ContractClass(typeof(UiCommand_Contract))]
    public interface IUiCommand : ICommandListItem, ICommand
    {
    }

    [ContractClassFor(typeof(IUiCommand))]
    internal abstract class UiCommand_Contract : IUiCommand
    {
        string ICommandListItem.Name
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        ImageSource ICommandListItem.Image
        {
            get { throw new NotImplementedException(); }
        }

        bool ICommand.CanExecute(object parameter)
        {
            throw new NotImplementedException();
        }

        event EventHandler ICommand.CanExecuteChanged
        {
            add { throw new NotImplementedException(); }
            remove { throw new NotImplementedException(); }
        }

        void ICommand.Execute(object parameter)
        {
            throw new NotImplementedException();
        }
    }

    [ContractClass(typeof(CommandGroup_Contract))]
    public interface ICommandGroup : ICommandListItem
    {
        IEnumerable<ICommandListItem> Items { get; }
    }

    [ContractClassFor(typeof(ICommandGroup))]
    internal abstract class CommandGroup_Contract : ICommandGroup
    {
        IEnumerable<ICommandListItem> ICommandGroup.Items
        {
            get 
            {
                Contract.Ensures(Contract.Result<IEnumerable<ICommandListItem>>() != null);
                throw new NotImplementedException(); 
            }
        }

        string ICommandListItem.Name
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        ImageSource ICommandListItem.Image
        {
            get { throw new NotImplementedException(); }
        }
    }

    public interface IShowProfileCommand : IUiCommand
    {
    }

    public interface IRequestPrivateChatCommand : IUiCommand
    {
    }

    public interface IAddContactCommand : IUiCommand
    {
        event EventHandler Completed;
    }

    public interface IDeleteContactCommand : IUiCommand
    {
        event EventHandler Completed;
    }

    public interface IShowLogInDialogCommand : IUiCommand
    {
        ISessionCredentials Credentials { get; set; }
        event EventHandler CredentialsChanged;
    }

    public interface ILogOutCommand : IUiCommand
    {
    }

    public interface IRegisterCommand : IUiCommand
    {
    }

    public interface IEditProfileCommand : IUiCommand
    {
    }

    public interface IGoToTextChatCommand : IUiCommand
    {
        event EventHandler Completed;
    }

    public interface IGoToContactListCommand : IUiCommand
    {
        event EventHandler Completed;
    }

    public interface IGoToUserSearchCommand : IUiCommand
    {
        event EventHandler Completed;
    }

    public interface IGoToMailboxCommand : IUiCommand
    {
    }

    public interface IGoToVoiceChatCommand : IUiCommand
    {
    }

    public interface IDiscoverSharedTalkCommand : IUiCommand
    {
    }

    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field, AllowMultiple = false)]
    public sealed class MenuCommandMetadataAttribute : OrderMetadataAttribute, IMenuCommandMetadata
    {
        public string Group { get; set; }
        public string Menu { get; set; }
    }

    public interface IMenuCommandMetadata : IOrderMetadata
    {
        [DefaultValue(null)]
        string Group { get; }
        string Menu { get; }
    }

    public static class Menus
    {
        public const string File = "File";
        public const string View = "View";
        public const string Tools = "Tools";
        public const string Help = "Help";

        public const string User = "User";
        public const string Rooms = "Rooms";
    }
}
